<?php

//*******************************************************
//* JAccelerator Component
//* http://fun.kubera.org
//* (C) Radoslaw Kubera
//* license http://www.gnu.org/copyleft/gpl.html GNU/GPL
//*******************************************************

/** ensure this file is being included by a parent file */
defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');

global $mosConfig_absolute_path;
include_once ($mosConfig_absolute_path."/components/com_joomlacache/joomlacache.php");

function com_uninstall() {
	global $database;
	$database->setQuery("drop table #__joomlacache");
	$database->query();

	JoomlaCacheUnInstallPlugin();
	//  JoomlaCacheUndeleteIndex();
	echo "JAccelerator was successfully uninstalled.";
}

function JoomlaCacheUnInstallPlugin() {
	global $database, $mosConfig_dbprefix, $mosConfig_absolute_path;
	$list = $database->getTableList();
	$table = $mosConfig_dbprefix.'plugins';
	$path = $mosConfig_absolute_path.'/plugins/system/';

	if(!in_array($table, $list)) {
		$table = $mosConfig_dbprefix.'mambots';
		$path = $mosConfig_absolute_path.'/mambots/system/';
	}

	$database->setQuery("select * from $table where element = 'joomlacache'");
	$database->loadObject($element);
	if($element) {
		if(@unlink($path.'joomlacache.php')) {
			if(@unlink($path.'joomlacache.xml')) {
				$database->setQuery("delete from $table where element='joomlacache'");
				$database->query();
				return 1;
			}
		}
	}
	return 0;
}

?>
